

<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="generator" content="HelpNDoc Personal Edition 7.3.0.348">
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="icon" href="favicon.ico"/>

  <title>Using Lua</title>
  <meta name="description" content="" /> 
  <meta name="keywords" content="">



  

  <!-- Twitter Card data -->
  <meta name="twitter:card" content="summary">
  <meta name="twitter:title" content="Using Lua">
  <meta name="twitter:description" content="">

  <!-- Open Graph data -->
  <meta property="og:title" content="Using Lua" />
  <meta property="og:type" content="article" />
  <meta property="og:description" content="" />
  <meta property="og:site_name" content="FCEUX Help" /> 

  <!-- Bootstrap core CSS -->
  <link href="vendors/bootstrap-3.4.1/css/bootstrap.min.css" rel="stylesheet"/>

  <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  <link href="vendors/bootstrap-3.4.1/css/ie10-viewport-bug-workaround.css" rel="stylesheet"/>

  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
      <script src="vendors/html5shiv-3.7.3/html5shiv.min.js"></script>
      <script src="vendors/respond-1.4.2/respond.min.js"></script>
    <![endif]-->

  <!-- JsTree styles -->
  <link href="vendors/jstree-3.3.10/themes/default/style.min.css" rel="stylesheet"/>

  <!-- Hnd styles -->
  <link href="css/layout.min.css" rel="stylesheet" />
  <link href="css/effects.min.css" rel="stylesheet" />
  <link href="css/theme-light-blue.min.css" rel="stylesheet" />
  <link href="css/print.min.css" rel="stylesheet" media="print" />
  <style type="text/css">nav { width: 250px} @media screen and (min-width:769px) { body.md-nav-expanded div#main { margin-left: 250px} body.md-nav-expanded header { padding-left: 264px} }</style>

  <!-- Content style -->
  <link href="css/hnd.content.css" rel="stylesheet" />

  



</head>

<body class="md-nav-expanded">



  <div id="skip-link">
    <a href="#main-content" class="element-invisible">Skip to main content</a>
  </div>

  <header class="headroom">
    <button class="hnd-toggle btn btn-default">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>        
    </button>
    <h1>FCEUX Help</h1>
    
  </header>

  <nav id="panel-left" class="md-nav-expanded">
    <!-- Nav tabs -->
    <ul class="tab-tabs nav nav-tabs" role="tablist">
      <li id="nav-close"> 
        <button class="hnd-toggle btn btn-default">
          <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
        </button>
      </li>
      
	  
        <li role="presentation" class="tab active">
            <a href="#contents" id="tab-contents" aria-controls="contents" role="tab" data-toggle="tab">
                <i class="glyphicon glyphicon-list"></i>
                Contents
            </a>
        </li>
      
        <li role="presentation" class="tab">
            <a href="#index" id="tab-index" aria-controls="index" role="tab" data-toggle="tab">
                <i class="glyphicon glyphicon-asterisk"></i>
                Index
            </a>
        </li>
      
        <li role="presentation" class="tab">
            <a href="#search" id="tab-search" aria-controls="search" role="tab" data-toggle="tab">
                <i class="glyphicon glyphicon-search"></i>
                Search
            </a>
        </li>
      
    </ul>  <!-- /Nav tabs -->

    <!-- Tab panes -->
    <div class="tab-content">
	  
      <div role="tabpanel" class="tab-pane active" id="contents">
        <div id="toc" class="tree-container unselectable"
            data-url="_toc.json"
            data-openlvl="1"
        >
            
        </div>
      </div>  <!-- /contents-->
      
      <div role="tabpanel" class="tab-pane" id="index">
        <div id="keywords" class="tree-container unselectable"
            data-url="_keywords.json"
            data-openlvl="1"
        >
            
        </div>
      </div>  <!-- /index-->
      
      <div role="tabpanel" class="tab-pane" id="search">
        <div class="search-content">
          <div class="search-input">
            <form id="search-form">
              <div class="form-group">
                <div class="input-group">
                  <input type="text" class="form-control" id="input-search" name="input-search" placeholder="Search..." />
                  <span class="input-group-btn">
                    <button class="btn btn-default" type="submit">
                      <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                    </button>
                  </span>
                </div>
              </div>
            </form>
          </div>  <!-- /search-input -->
          <div class="search-result">
            <div id="search-info"></div>
            <div class="tree-container unselectable" id="search-tree"></div>
          </div>  <!-- /search-result -->
        </div>  <!-- /search-content -->
      </div>  <!-- /search-->
      
    </div>  <!-- /Tab panes -->

  </nav>

  <div id="main">

    <article>
        <div id="topic-content" class="container-fluid" 
		  data-hnd-id="Commands"
		  data-hnd-context="61"
		  data-hnd-title="Using Lua"
		>
            
                <div class="navigation">
                    <ol class="breadcrumb">
                        <li><a href="LuaScripting.html">Lua Scripting</a></li>
                    </ol>
                    <div class="nav-arrows">
                        <div class="btn-group btn-group" role="group"><a class="btn btn-default" href="LuaScripting.html" title="Lua Scripting" role="button"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span></a><a class="btn btn-default" href="LuaGettingStarted.html" title="Getting Started" role="button"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span></a><a class="btn btn-default" href="LuaFunctionsList.html" title="Lua Functions List" role="button"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></a></div>
                    </div>
                </div> 
            

            <a id="main-content"></a>

            <h2>Using Lua</h2>

            <div class="main-content">
                
<p class="rvps2"><span class="rvts6">(written by qFox)</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts37">Introduction</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Lua is a scripting language. It is used in games like Farcry and World of Warcraft (and many other games and applications!). Even though you can find all kinds of tutorials online, let me help you with the basics.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">I will assume you are at least somewhat familiar with the basics of programming. So basic stuff like arrays, variables, strings, loops and if-then-else and branching are not explained here.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">A hello world EmuLua program looks like this:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">while (true) do</span></p>
<p class="rvps2"><span class="rvts6"></span><span class="rvts6"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="rvts6">gui.text(50,50,"Hello world!");</span></p>
<p class="rvps2"><span class="rvts6"></span><span class="rvts6"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="rvts6">emu.frameadvance();</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">When you load the script, the emulator will sort of go into pause mode and hand controls over to Lua (you!). Hence you are responsible for frameadvancing the emulator.</span></p>
<p class="rvps2"><span class="rvts6">IF YOU DO NOT CALL emu.frameadvance AT THE CYCLE OF THE MAIN LOOP YOU WILL FREEZE THE EMULATOR! There. You have been warned. Don't worry though, you'll make this mistake at least once. Just force-quit the application and try again :)</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts37">Syntax</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Now then. Just like any other language, Lua has a few quirks you should be aware of.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">First of all, if's require a then and end. After a couple of days intensive Lua coding, I still make this mistake myself, but the Lua interpreter will prompt you of such errors on load, so don't worry too much about it. So:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">if (something) then</span></p>
<p class="rvps2"><span class="rvts6"></span><span class="rvts6"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="rvts6">dostuff</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Lua uses nil instead of null.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">There are only two values that evaluate to "false", these are "nil" and "false". ANYTHING else will evaluate to true, even 0 or the empty string.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Comments are denoted by two consecutive dashes; --. Anything after it on the same line is a comment and ignored by Lua. There is no /* */ type of commenting in Lua.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Variables have a local and global scope. You explicitly make a variable local by declaring it with the "local" keyword.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">somethingglobal; -- accessible by any function or flow</span></p>
<p class="rvps2"><span class="rvts6">local something; -- only known to the same or deeper scope as where it was declared</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Note that variables declared in for loops (see below) are always considered local.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Arrays are called tables in Lua. To be more precise, Lua uses associative arrays.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Do not rely on the table.length() when your table can contain nil values, this function stops when it encounters a nil value, thus possibly cutting your table short.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">One experienced programmers will have to get used to is the table offset; tables start at index 1, not 0. That's just the way it is, deal with it.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">There are a few ways to create a table:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">local tbl1 = {}; -- empty table</span></p>
<p class="rvps2"><span class="rvts6">local tbl2 = {"a","b","c","d"}; -- table with 5 strings</span></p>
<p class="rvps2"><span class="rvts6">local tbl3 = {a=1,b=2,c=3}; -- associative table with 3 numbers</span></p>
<p class="rvps2"><span class="rvts6">local tbl4 = {"a",b=2,c="x","d"=5}; -- associative table with mixed content</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Note that you can mix up the data in one table, as shown by tbl4.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">You can refer to table values in a few equivalent manners, using the examples above:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">tbl1[1] -- = nil because tbl1 is empty</span></p>
<p class="rvps2"><span class="rvts6">tbl2[2] -- = "b"</span></p>
<p class="rvps2"><span class="rvts6">tbl3["a"] -- = 1</span></p>
<p class="rvps2"><span class="rvts6">tbl4.b -- = 2</span></p>
<p class="rvps2"><span class="rvts6">tbl2.3 -- = "c"</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">When the argument of a function is just a table, the parantheses "()" are optional. So for instance:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">processTable({a=2,b=3});</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Is equivalent to</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">processTable{a=2,b=3};</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Another notation that's equivalent is</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">filehandle.read(filehandle, 5);</span></p>
<p class="rvps2"><span class="rvts6">filehandle:read(5);</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">When using the colon notation ":" Lua will call the function adding the self-reference to the front of the parameterstack.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Functions behave like objects and are declared in the follow manner:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">function doSomething(somevalue, anothervalue)</span></p>
<p class="rvps2"><span class="rvts6"></span><span class="rvts6"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="rvts6">dostuffhere</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">So no curly braces "{}" !</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Some flow control:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">for i=0,15 do</span></p>
<p class="rvps2"><span class="rvts6">&nbsp; -- do stuff here, i runs from 0 to 15 (inclusive!)</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">for key,value in pairs(table) do</span></p>
<p class="rvps2"><span class="rvts6">&nbsp; -- do stuff here. pairs will iterate through the table, splitting the keys and values</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">while (somethingistrue) do</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">if (somethingistrue) then</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">if (somethingistrue) then</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">else</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">if (somethingistrue) then</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">elseif (somethingelseistrue) then</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">For comparison, you only have to remember that the exclamationmark is not used. Not equal "!=" is written like tilde-equals "~=" and if (!something) then ... is written with "not " in front of it; if (not something) then...</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">For easy reference to the standard libraries look on the bottom half of this page: http://www.lua.org/manual/5.1/</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts37">Lua in FCEUX</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Now then, let's get to the emulator specifics!</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">To load a Lua script in FCEU first load a rom (Lua can only do things after each frame cycle so load a rom first). Go to file, at the bottom choose Run Lua Script and select and load the file.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">When Lua starts, the emulator pauses and hands control over to Lua. Lua (that's you!) decides when the next frame is processed. That's why it's very common to write an endless while loop, exiting the main loop of a script will exit the script and hand control back to the emulator. This also happens when a script unexpectingly crashes.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">A bare script looks like this:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">while (true) do</span></p>
<p class="rvps2"><span class="rvts6">&nbsp; emu.frameadvance();</span></p>
<p class="rvps2"><span class="rvts6">end;</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">And is about equal to not running Lua at all. The frameadvance function is the same called internally, so no loss of speed there!</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Bitwise operators:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Lua does not have bitwise operators, so we supply some for you. These are common bitwise operators, nothing fancy.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">AND(a,b);</span></p>
<p class="rvps2"><span class="rvts6">OR(a,b);</span></p>
<p class="rvps2"><span class="rvts6">XOR(a,b);</span></p>
<p class="rvps2"><span class="rvts6">BIT(n); -- returns a number with only bit n set (1)</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">The emulator specific Lua is equal to the one of snes9x, with some platform specific changes (few buttons, for instance).&nbsp;</span></p>
<p class="rvps2"><span class="rvts6">You can find the reference here: </span><a class="rvts96" href="http://dehacked.2y.net/snes9x-lua.html" target="_blank">http://dehacked.2y.net/snes9x-lua.html</a></p>
<p class="rvps2"><span class="rvts6">The following is a quick reference, you can go to the snes9x reference for more details.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">To paint stuff on screen, use the gui table. This contains a few predefined functions to manipulate the main window. For any coordinate, 0,0 is the top-left pixel of the window. You have to prevent out-of-bound errors yourself for now. If a color can be passed on, it is a string. HTML-syntax is supported ("#34053D"), as well as a FEW colors ("red", "green", "blue" ...).</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">gui.text(x, y, str); -- Print a line to the window, you can use \n for a return but it will only work once</span></p>
<p class="rvps2"><span class="rvts6">gui.pixel(x, y, color); -- plot a pixel at the given coordinate</span></p>
<p class="rvps2"><span class="rvts6">gui.line(x1, y1, x2, y2, color); -- plot a line from x1,y1 to x2,y2</span></p>
<p class="rvps2"><span class="rvts6">gui.box(x1, y1, x2, y2, color); -- draw a square from x1,y1 to x2,y2</span></p>
<p class="rvps2"><span class="rvts6">gui.popup(str); -- pops up a messagebox informing the user of something. Real handy when debugging!</span></p>
<p class="rvps2"><span class="rvts6">gui.getpixel(x,y); -- return the values of the pixel at given position. Returns three numbers of the emulator image before paiting is applied.</span></p>
<p class="rvps2"><span class="rvts6">gui.gdscreenshot(); -- Takes a screen shot of the image and returns it in the form of a string which can be imported by the gd library using the gd.createFromGdStr() function</span></p>
<p class="rvps2"><span class="rvts6">(for more gd functions see DeHackED's reference: http://dehacked.2y.net/snes9x-lua.html)</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">PAINTING IS ALWAYS ONE FRAME BEHIND! This is because the painting is done at the creation of the next frame, not while Lua is running.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Emulator control:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">emu.frameadvance(); -- advances emulation ONE frame</span></p>
<p class="rvps2"><span class="rvts6">emu.pause(); -- same as pressing the pause button</span></p>
<p class="rvps2"><span class="rvts6">emu.speedmode(strMode); -- Supported are "normal","turbo","nothrottle","maximum". But know that except for "normal", all other modes will run as "turbo" for now.</span></p>
<p class="rvps2"><span class="rvts6">emu.wait(); -- skips the emulation of the next frame, in case your script needs to wait for something</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Memory control:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">memory.readbyte(adr); -- read one byte from given address and return it. Besides decimal values Lua also allows the hex notation 0x00FA. In FCEUX reading is done BEFORE the cheats are applied!</span></p>
<p class="rvps2"><span class="rvts6">memory.writebyte(adr, value); -- write one byte to the RAM of the NES. writing is done AFTER the hexeditor receives its values, so if you are freezing an address by Lua, it will not show in the hex editor (but it will in the game :)</span></p>
<p class="rvps2"><span class="rvts6">memory.readbytesigned(adr); -- same as readbyte, except this returns a signed value, rather then an unsigned value.</span></p>
<p class="rvps2"><span class="rvts6">memory.register(adr, function); -- binds a function to an address. The function will be called when an address changes. NOTE THAT THIS IS EXPENSIVE (eg.: slow)! Only one function allowed per address.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Input control:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">You can read and write input by using the joypad table. A input table has the following (case sensitive) keys, where nil denotes they are not to be pressed: up down left right start select A B</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">joypad.read(playern); -- get the input table for the player who's input you want to read (a number!)</span></p>
<p class="rvps2"><span class="rvts6">joypad.write(playern, inputtable); -- set the input for player n. Note that this will overwrite any input from the user, and only when this is used.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">Savestates:</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">You can load and save to the predefined savestates 1 ... 9 or create new "anonymous" savestates. You must first create a savestate object, which is your handle to a savestate. Then you can pass this handle on to savestate.load or save to do so.</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">savestate.create(n); -- n is optional. When supplied, it will create a savestate for slot n, otherwise a new (anonymous) savestate object is created. Note that this does not yet save or load anything!</span></p>
<p class="rvps2"><span class="rvts6">savestate.load(state); -- load the given savestate</span></p>
<p class="rvps2"><span class="rvts6">savestate.save(state); -- save the given savestate</span></p>
<p class="rvps2"><span class="rvts6"><br/></span></p>
<p class="rvps2"><span class="rvts6">For an up-to-date list of functions, see the </span><a class="rvts96" href="LuaFunctionsList.html">Lua Functions List</a><span class="rvts6">.</span><span class="rvts6"></span></p>
<p class="rvps4" style="clear: both;"><span class="rvts18">Created with the Personal Edition of HelpNDoc: </span><a class="rvts19" href="https://www.helpauthoringsoftware.com">Benefits of a Help Authoring Tool</a></p>

            </div>
            
            <div id="topic_footer"><div id="topic_footer_content">2020</div></div>
        </div>  <!-- /#topic-content -->
    </article>

    <footer></footer>

  </div>  <!-- /#main -->

  <div class="mask" data-toggle="sm-nav-expanded"></div>
  
  <!-- Modal -->
  <div class="modal fade" id="hndModal" tabindex="-1" role="dialog" aria-labelledby="hndModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="hndModalLabel"></h4>
        </div>
        <div class="modal-body">
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary modal-btn-close" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>

  <!-- Splitter -->
  <div id="hnd-splitter" style="left: 250px"></div>  

  <!-- Scripts -->
  <script src="vendors/jquery-3.5.1/jquery.min.js"></script>
  <script src="vendors/bootstrap-3.4.1/js/bootstrap.min.js"></script>
  <script src="vendors/bootstrap-3.4.1/js/ie10-viewport-bug-workaround.js"></script>
  <script src="vendors/markjs-8.11.1/jquery.mark.min.js"></script>
  <script src="vendors/uri-1.19.2/uri.min.js"></script>
  <script src="vendors/imageMapResizer-1.0.10/imageMapResizer.min.js"></script>
  <script src="vendors/headroom-0.11.0/headroom.min.js"></script>
  <script src="vendors/jstree-3.3.10/jstree.min.js"></script>  
  <script src="vendors/interactjs-1.9.22/interact.min.js"></script>  

  <!-- HelpNDoc scripts -->
  <script src="js/polyfill.object.min.js"></script>
  <script src="_translations.js"></script>
  <script src="js/hndsd.min.js"></script>
  <script src="js/hndse.min.js"></script>
  <script src="js/app.min.js"></script>

  <!-- Init script -->
  <script>
    $(function() {
      // Create the app
      var app = new Hnd.App();
      // Update translations
      hnd_ut(app);
	  // Instanciate imageMapResizer
	  imageMapResize();
	  // Custom JS
	  
      // Boot the app
      app.Boot();
    });
  </script>



</body>

</html>

